﻿#region

using System;
using System.Collections.Generic;
using System.Diagnostics;

#endregion

namespace Domain {
    [DebuggerDisplay("{VerticesString}")]
    public class Edge : IEdge {
        public Vertex VertexStart { get; private set; }
        public Vertex VertexEnd { get; private set; }
        public int Weight { get; private set; }

        public Edge(Vertex vertexStart, Vertex vertexEnd, int weight)
        {
            VertexStart = vertexStart;
            VertexEnd = vertexEnd;
            Weight = weight;
        }

        public Edge(Vertex vertexStart, Vertex vertexEnd) : this(vertexStart, vertexEnd, 1) {}

        public Edge() {}

        public List<Vertex> Vertices {
            get { return new List<Vertex> { VertexStart, VertexEnd }; }
            set {
                if (value.Count != 2)
                    throw new ApplicationException("У обыкновенного ребра должно быть ровно две вершины");
                VertexStart = value[0];
                VertexEnd = value[1];
            }
        }
    }
}